#ifndef MENU_H
#define	MENU_H

#include <allegro5/allegro.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_ttf.h>
#include <allegro5/allegro_primitives.h>
#include "data_struct_bttn.h"


 extern ALLEGRO_DISPLAY *display;
 extern ALLEGRO_EVENT_QUEUE *event_queue;
 extern ALLEGRO_TIMER *timer;
 extern ALLEGRO_FONT *font50;
 extern ALLEGRO_FONT *font18;
 extern ALLEGRO_EVENT ev;
  
 extern bool done; 
 extern const unsigned short int WIDTH_DISPLAY;
 extern const unsigned short int HEIGHT_DISPLAY;
 
 extern const unsigned short int BUTTON_LENGHT;
 extern unsigned int MASK;
 
 ///These enumerators rappresent the states of the state machine.
/** 
 * @enum btt_name is an enumerator used to indicate the button in use
 * according to the position in the array menu_bttn that is in declared 
 * in the main.
 */
enum bttn_name {newgame, leaderBoard, quitting, back};

 
 ///The function displays the button.
/**
 * The function draws the buttons.
 * @param drawbttn is drawed by the function and writes the text inside the 
 *	button, it accepts in input thisb
 * @param thisb is a structure that represents the current button.
 */
 
 void DrawBttn (bttnbox);
 
 ///This function initializes a button.
 /**
 * It takes the following parameters in input and puts them in the right ù
 * variables of the button.
 * @param thisb is the button that has to be initialized
 * @param cntr_x is the x value of the upper left corner of the button box
 * @param cntr_y is the y value of the upper left corner of the button box
 * @param thistext is a string containing the text that will be displayed in the
 * text field of the button.
 
 */
 
 void InitBttn(bttnbox &thisb, float cntr_x, float cntr_y, char thistext[]);
 
 ///In InitAllegro there is all the initialization of allegro needed by Tetris.
 /**
  * First of all we initialize allegro then we install all add-on concerning
  * the font, the installation of mouse and keyboard and at least we create the
  * timer and we set the event listener to catch all the event we need.
  *
  * @return At the end we have a boolean as return of the function that tell us
  * if everything goes right or something doesn't work.
  * 
  * Back to: main()
  */
bool InitAllegro ();

/// The menu implements a state machine and manages the switch between these states.
/**
 * The menu puts together all the different parts of the game.
 * There is a loop that catches the input from mouse, checks the position and if a button
 * is pushed. 
 * If a button is pushed, the state variable change and in the loop we invoke a
 * the right low level function and the right display redrawing function.
 * 
 * @param redraw we refreshed the screen only when we have this variable at true and 
 *	we don't have other event in our event_queue.
 *
 * In the menù we can access to the core of the game Game()	 
 */
int Menu ();

///Destroy the dynamic element declared in the software
/**
* Destroy the dynamic element declared and unistall the 
* ALLEGRO ADD-ON used in the software.
**/
void Close ();
#endif	/* MENU_H */
